package com.gaoshi.chapter5;

public class ManagerTest {
    public static void main(String[] args) {
        Manager boss = new Manager("Carl Cracker", 80000, 1987, 12, 15);
        boss.setBonus(5000);

        var staff = new Employee[3];

        staff[0] = boss;
        staff[1] = new Employee("Harry Hacker", 50000, 1989, 10, 1);
        staff[2] = new Employee("Tony Tester", 40000, 1990, 3, 15);

        // 在将超类强转为子类之前，应使用 instanceof 进行检查
        if (staff[0] instanceof Employee) {
            System.out.println("Manager is a instance of Employee.");
        }

        if (staff[1] instanceof  Manager) {
            System.out.println("Employee is a instance of Manager.");
        }

        for (Employee employee : staff) {
//            System.out.println(employee.getName() + " " + employee.getSalary());
            System.out.println(employee);
        }

        System.out.println(staff[1].equals(boss));
        System.out.println(boss.equals(staff[1]));

        // toString
        System.out.println(System.out);
    }
}
